// World.h

// Informacie o okolitom prostredi hraca

#ifndef WORLD_H
#define WORLD_H

// For debugging SB and VI recalculation
//#define WORLD_RECALC_DBG DBGN
#define WORLD_RECALC_DBG DO_NOTHING

// For debugging the World contents
//#define WORLD_STATS_DBG DBGN
#define WORLD_STATS_DBG DO_NOTHING

#define MAX_PLAYER_AGE 15

// Svet hraca pozostava z lopty, hracov, seba, stavu, parametrov a premennych
class Ball;
class Player;
class Myself;
class State;
class Params;
class Variables;

struct FEEDBACK_DATA;

#include "Player/Interfaces/Synchronization.h"
//#include "Common/Protocol/ParseStructs.h"
//#include "Common/World/ParamStructs.h"
//#include "Common/World/Types.h"
#include "Common/Support/DynArray.h"
#include "Common/Support/Debug.h"


// Model sveta
class World
{
	
	static SynchronizationInterface* synchro;

protected:
	void RecalculateFriends(const SENSE_BODY* sb, const VISUAL_INFO* vi);
	void RecalculateEnemies(const SENSE_BODY* sb, const VISUAL_INFO* vi);

public:

	// Model sveta pozostava zo:
	Ball*	ball;
	Myself*	me;

	// Preco 32 buniek?
	DynArray<Player, 32> friends;
	DynArray<Player, 32> enemies;

	State* state;
	Params* params;
	Variables* variables;
	
	// Preco 12 hracov? 
	PLAYER_TYPE* friendTypes[12];
	

	// Konstruktor
	World();
	// Kopirovaci konstruktor
	World(const World& world);
	// Destruktor
	virtual ~World();
	
	// Metody

	Player* FindEnemy(int uniform) const;
	int FindEnemyIndex(int uniform) const;
	Player* FindFriend(int uniform) const;
	int FindFriendIndex(int uniform) const;
	
	// Pouzitie ulozenych udajov na aktualizovanie sveta
	void ApplyFeedback(FEEDBACK_DATA* fd);
	// Inicializovanie synchronizacnej premennej
	static void BindInterfaces();
	// Zostavenie sveta z informacii servera
	void ProcessInfo(const SENSE_BODY* sb, const VISUAL_INFO* vi);
	// Znovu precita informacie o type hraca a nalinkuje ich na hracov
	void RelinkPlayerTypes();
	//
	void Step();
	//
	void SetPlayerType(Side side, int uniform, int type);
		
};

#include "Player/World/State.h"
#include "Player/World/Params.h"
#include "Player/World/Variables.h"
#include "Player/World/Ball.h"
#include "Player/World/Player.h"
#include "Player/World/Myself.h"

#endif // WORLD_H
